<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <title></title>
    <script src="../js/vue.js"></script>
</head>
<body>
<div id="app">
    <el-button type="primary" @click="doBuy()" round>按钮</el-button>
    <p>{{msg}}</p>
    <!-- <span id="result"></span> -->
</div>
<!--import Vue before Element-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="../js/axios.min.js"></script>
<script type="text/javascript">
    new Vue({
        el: "#app",
        data() {
            return {
                msg: ""
            }
        },
        methods: {
            doBuy() {
                console.log("==doBuy==")
                let url = "http://localhost:9000/nacos/provider/echo/1"
                //let span = document.getElementById("result")
                axios.get(url)
                    .then(
                        promise => {
                            console.log(promise)
                            if (!promise.data.status) {
                                this.msg = promise.data
                                //span.innerHTML = promise.data
                            } else {
                                this.msg = promise.data.message
                                //span.innerHTML = promise.data.message
                            }
                        })
                    .catch(
                        error => {
                            if (error.promise.status === 429) {
                                this.msg = error.promise.statusText
                                //span.innerHTML = error.promise.statusText
                            }
                        })
            }
        }
    })
</script>
</body>
</html>
